@extends('admin::layouts.master')
@section('title')
    会员列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 200px;">
                                <input type="text" name="title" placeholder="标题" value="{{$arr_search['title']}}" autocomplete="off" class="layui-input"></div>

                            <div class="layui-input-inline" style="width: 200px;">
                                <select name="pid" class="goods_cate" >
                                    <option value="">请选择分类</option>
                                    <option value="1" @if( $arr_search['pid'] == 1 ) selected="" @endif >保养专区</option>
                                    <option value="2" @if( $arr_search['pid'] == 2 ) selected="" @endif >检测专区</option>
                                    <option value="3" @if( $arr_search['pid'] == 3 ) selected="" @endif >新闻专区</option>
                                </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small"  onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加','{{route("shop_discover_create")}}')">
                            <i class="layui-icon"></i>添加</button>
                    </div>
                    <div class="layui-card-body " style="overflow-x: auto;">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>图像</th>
                                <th>标题</th>
                                <th>分类</th>
                                <th>浏览量</th>
                                <th>点赞数</th>
                                <th>评论数量</th>
                                <th>添加时间</th>
                                <th>新闻状态</th>
                                <th>审核时间</th>
                                <th>审核说明</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                            <tr>
                                <td>{{ $value['id'] }}</td>
                                <td><img src="{{ $value['img']['full_src'] }}" style="width: 80px;height: 80px;"></td>
                                <td>{{ $value['title'] }}</td>
                                <td>{{ $value['pid']['name'] }}</td>
                                <td>{{ $value['look_num'] }}</td>
                                <td>
                                    <a title="点赞详情" onclick="xadmin.open('点赞详情','{{route('shop_discover_detail',['act'=>'zan','id'=>$value['id']])}}')" href="javascript:;">{{ $value['count_zan_count'] }}（详情）</a>
                                </td>
                                <td>
                                    <a title="评论详情" onclick="xadmin.open('评论详情','{{route('shop_discover_detail',['act'=>'ping','id'=>$value['id']])}}')" href="javascript:;">{{ $value['count_ping_count'] }}（详情）</a>
                                </td>
                                <td>{{ $value['created_at'] }}</td>
                                <td>
                                    @if( $value['status'] == 1 )
                                        已发布
                                    @elseif( $value['status'] == 2 )
                                        待审核
                                    @else
                                        审核失败
                                    @endif
                                </td>
                                <td>
                                    @if( $value['status'] == 2 )
                                        -
                                    @else
                                        {{ $value['updated_at'] }}
                                    @endif
                                </td>
                                <td>{{ $value['remark'] }}</td>
                                <td class="td-manage">
                                    @if( $value['status'] != 1 )
                                        <a title="编辑" class="layui-btn" onclick="xadmin.open('编辑','{{route('shop_discover_edit',['id'=>$value['id']])}}')" href="javascript:;">编辑</a>
                                    @endif
                                    <a title="删除" class="ajax_member_del layui-btn layui-btn-danger" data-href="{{route('shop_discover_del',['id'=>$value['id']])}}" data-title="确定删除吗？请谨慎操作" href="javascript:;">删除</a>
                                </td>
                            </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

                form.on('switch(switchTest)', function(data){
                    var id = $(this).attr('data-id');
                    var status = 1;
                    if( $(this).attr('data-status') == 1 ){
                        status = 2;
                    }
                    $.ajax({
                        url: js_url('shop-user-update'),
                        type: 'post',
                        data: {id:id,status:status,'_token': '{{csrf_token()}}'},
                        dataType: "json",
                        success: function (result) {
                            if (result.state === 0) {
                                    layer.msg(result.msg, {time: 500, icon: 6}, function () {
                                });
                            } else {
                                layer.msg(result.msg, {time: 2000, icon: 5});
                            }
                        }
                    });
                });
               
            })
    </script>
@endsection




